<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>SemOpt: src/SATFormulae.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">SemOpt
   &#160;<span id="projectnumber">0.2alpha5-SCC</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('SATFormulae_8cpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/SATFormulae.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="SATFormulae_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;SATFormulae.h&quot;</span>
<a name="l00010"></a>00010 
<a name="l00014"></a><a class="code" href="classSATFormulae.html#a5120c3a2469b8124be715fa0d97fc545">00014</a> <a class="code" href="classSATFormulae.html#a5120c3a2469b8124be715fa0d97fc545" title="Simple constructor.">SATFormulae::SATFormulae</a>()
<a name="l00015"></a>00015 {
<a name="l00016"></a>00016         this-&gt;clauses_and = vector&lt;OrClause&gt;();
<a name="l00017"></a>00017 }
<a name="l00018"></a>00018 
<a name="l00024"></a><a class="code" href="classSATFormulae.html#a24f192aef15c7338da94440fbf11a1fd">00024</a> <span class="keywordtype">void</span> <a class="code" href="classSATFormulae.html#a24f192aef15c7338da94440fbf11a1fd" title="Method for appending a new OrClause to the other clause.">SATFormulae::appendOrClause</a>(<a class="code" href="classOrClause.html" title="Class encompassing a list of SAT variables (type `Variable`) linked by or operators.">OrClause</a> c)
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026         this-&gt;clauses_and.push_back(c);
<a name="l00027"></a>00027 }
<a name="l00028"></a>00028 
<a name="l00034"></a><a class="code" href="classSATFormulae.html#aa2f0f69c190ff01d8ab48e426d89e665">00034</a> <span class="keywordtype">void</span> <a class="code" href="classSATFormulae.html#aa2f0f69c190ff01d8ab48e426d89e665" title="Method for transforming the SAT formulae into a string `DIMACS` compliant.">SATFormulae::toSS</a>(stringstream *ss)<span class="keyword"> const</span>
<a name="l00035"></a>00035 <span class="keyword"></span>{
<a name="l00036"></a>00036         <span class="keywordtype">string</span> newline = <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00037"></a>00037         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; (int) this-&gt;clauses_and.size(); i++)
<a name="l00038"></a>00038         {
<a name="l00039"></a>00039                 (*ss) &lt;&lt; this-&gt;clauses_and.at(i);
<a name="l00040"></a>00040                 <span class="keywordflow">if</span> (i != (<span class="keywordtype">int</span>) this-&gt;clauses_and.size() - 1)
<a name="l00041"></a>00041                         (*ss) &lt;&lt; newline;
<a name="l00042"></a>00042         }
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 ostream&amp; <a class="code" href="Argument_8cpp.html#a76ef732a0021f3ac6698582cf94a079e">operator&lt;&lt;</a>(ostream&amp; out, <span class="keyword">const</span> <a class="code" href="classSATFormulae.html" title="Class encompassing a list of `OrClause` linked by and operators.">SATFormulae</a>&amp; r)
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048         stringstream ss(stringstream::in | stringstream::out);
<a name="l00049"></a>00049         r.<a class="code" href="classSATFormulae.html#aa2f0f69c190ff01d8ab48e426d89e665" title="Method for transforming the SAT formulae into a string `DIMACS` compliant.">toSS</a>(&amp;ss);
<a name="l00050"></a>00050         out &lt;&lt; ss.str();
<a name="l00051"></a>00051         <span class="keywordflow">return</span> out;
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053 
<a name="l00058"></a><a class="code" href="classSATFormulae.html#a8f519b3240b275633769ed70c9583d5d">00058</a> <span class="keywordtype">int</span> <a class="code" href="classSATFormulae.html#a8f519b3240b275633769ed70c9583d5d" title="Method returning the number of OrClause.">SATFormulae::size</a>()
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060         <span class="keywordflow">return</span> (<span class="keywordtype">int</span>) this-&gt;clauses_and.size();
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 
<a name="l00068"></a><a class="code" href="classSATFormulae.html#a613cef1d45631a255b65718f51c5024c">00068</a> <span class="keywordtype">void</span> <a class="code" href="classSATFormulae.html#a613cef1d45631a255b65718f51c5024c" title="Method for cloning (not coping the pointers) this object into a new one.">SATFormulae::clone</a>(<a class="code" href="classSATFormulae.html" title="Class encompassing a list of `OrClause` linked by and operators.">SATFormulae</a> *newsat)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070         (*newsat) = <a class="code" href="classSATFormulae.html#a5120c3a2469b8124be715fa0d97fc545" title="Simple constructor.">SATFormulae</a>();
<a name="l00071"></a>00071         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; this-&gt;<a class="code" href="classSATFormulae.html#a8f519b3240b275633769ed70c9583d5d" title="Method returning the number of OrClause.">size</a>(); i++)
<a name="l00072"></a>00072         {
<a name="l00073"></a>00073                 <a class="code" href="classOrClause.html" title="Class encompassing a list of SAT variables (type `Variable`) linked by or operators.">OrClause</a> newor = <a class="code" href="classOrClause.html" title="Class encompassing a list of SAT variables (type `Variable`) linked by or operators.">OrClause</a>();
<a name="l00074"></a>00074                 this-&gt;clauses_and.at(i).clone(&amp;newor);
<a name="l00075"></a>00075                 (*newsat).appendOrClause(newor);
<a name="l00076"></a>00076         }
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 
<a name="l00084"></a><a class="code" href="classSATFormulae.html#a7c56233149efa47f3533010b09daf42b">00084</a> <span class="keywordtype">bool</span> <a class="code" href="classSATFormulae.html#a7c56233149efa47f3533010b09daf42b" title="Check if there are no formulae.">SATFormulae::empty</a>()
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086         <span class="keywordflow">return</span> this-&gt;clauses_and.empty();
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 SATFormulae::~SATFormulae()
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="SATFormulae_8cpp.html">SATFormulae.cpp</a>      </li>

    <li class="footer">Generated on Fri Jan 17 2014 11:47:51 for SemOpt by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
